<% form_for(@document, :html => {:multipart => true}) do |f| %>
  <%= f.error_messages %>

  <% unless @document.new_record? %>
    <p>
      <b>Title:</b>
      <%=h @document.title %>(<%=h number_to_human_size @document.size %>)
    </p>

    <p>
      <b>Preview:</b>
      <% if Document::IMAGE.include?(@document.content_type) %>
        <%= image_tag url_for :controller => :documents, :action => :image, :id => @document.id %>
      <% else %>
        <%= link_to 'Download', {:controller => :documents, :action => :item, :id => @document.id} %>
      <% end %>
    </p>

    <p>
      <b>Content Type:</b>
      <%=h @document.content_type %>
    </p>
  <% end %>

  <p>
    Upload file<br/>
    <%= f.file_field :document_file %>
  </p>
  <p>
    <%= f.label :description %><br />
    <%= f.text_field :description %>
  </p>
  <p>
    <%= f.submit @document.new_record? ? 'Create' : 'Update' %>
  </p>
  
<% end %>